551. 学生出勤记录 I
为保证权益,题目请参考 551. 学生出勤记录 I(From LeetCode).
解决方案1
Python
python
# 551. 学生出勤记录 I
# https://leetcode-cn.com/problems/student-attendance-record-i/
class Solution:
def checkRecord(self, s: str) -> bool:
aCount = 0
freLate = 0
for st in s:
if st == "A":
aCount += 1
if st == "L":
freLate += 1
if freLate >= 3:
break
else:
freLate = 0
return aCount < 2 and freLate < 3
if __name__ == "__main__":
solution = Solution()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24